package com.ml.mall.mapper.credit;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ml.mall.bean.req.credit.CreditQueryDto;
import com.ml.mall.bean.res.credit.CreditQueryRes;
import com.ml.mall.entity.credit.SysCredit;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface SysCreditMapper extends BaseMapper<SysCredit> {
    //更新余额：直接传负；直接减少
    @Update("update sys_credit set credit_balance= credit_balance+ #{money} where company_id = #{companyId}")
    int  updateCreditBalanceByCompanyId(@Param("money") BigDecimal money, @Param("companyId") Long companyId);
    /**
     * @description    :通过公司自定义id查询出公司余额
     * @author         :zxm
     * @date           :2021/5/19
    **/
    SysCredit selectByCompanyId(@Param("companyId") Long companyId);

    /**
     * @description    :分页查询公司余额
     * @author         :zxm
     * @date           :2021/5/19
    **/
    List<CreditQueryRes> selectPageCredit(@Param("dto") CreditQueryDto dto);

    /**
     * @description    :分页查询总条数
     * @author         :zxm
     * @date           :2021/5/19
    **/
    Long selectCountCredit(@Param("dto")CreditQueryDto dto);
}